<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回调页面</title>
    <script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>
    <script src="plugins/axios/dist/axios.js"></script>
    <script src="plugins/vue/dist/vue.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
    <div id="Div">
        <h1>来啦，老弟</h1>
    </div>
<script type="text/javascript">
    new Vue({
        el:"#Div",
        data: {},
        methods:{

        },
        mounted(){
            let paramObj=str2Obj(location.href)
            //console.log(paramObj)
            let requestObj={code:paramObj.code}
            this.$http.post("/logininfo/wechat/login",requestObj)
            .then(result=>{
                result=result.data;
                console.log(result);
                if (result.success){
                    alert("登录成功");
                    let {token,loginInfo}=result.result;
                    localStorage.getItem("loginInfo",JSON.stringify(loginInfo));
                    localStorage.getItem("token",token);
                    location.href="/index.html";
                }
                if (!result.success && result.message=="toBind"){
                    let {accesstoken,openid}=result.result;
                    location.href="/binder.html?accesstoken="+accesstoken+"&openid="+openid;
                }
            }).catch(result=>{
                alert("操作失误！！")
            })

        }
    })
</script>
</body>
</html>